import HTMLParser
import urllib
import re


urlString="http://www.bigape.us/"
check=False
check2=False
urlText=[]

class ParseIXP(HTMLParser.HTMLParser):
    def handle_starttag(self,tag,attrs):
        global check
        global check2
        if tag=="tr":
            for name,value in attrs:
                if name=="bgcolor" and value=="white":
                    check=True
        elif tag=="td" and check==True:
            check2=True
           
                    
    def handle_data(self,data):
        global check
        global check2
        if data!='\n' and check==True:
            if(re.search("^\d\d*$",data)):
                check2=False
                check=False 
                urlText.append(data)
                  
            
lparser=ParseIXP()
lparser.feed(urllib.urlopen(urlString).read())
filePath="ixp_members.txt"
file = open(filePath,"a")
for item in urlText:
    #print item
    print >> file, "81 %s" % item
file.close()